<template>
    <div>
        <!--阿里云播放样式-->
        <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.8.1/skins/default/aliplayer-min.css" />
        <!--阿里云播放脚本-->
        <script charset="utf-8" type="text/javascript" src="https://g.alicdn.com/de/prismplayer/2.8.1/aliplayer-min.js"></script>
        <!--定义播放器dom-->
        <div id="J_prismPlayer" class="prism-player"/>
    </div>
</template>

<script>
import vod from '@/api/vod'
export default {
    layout:'video',//应用video布局
    asyncData({params,error}){
        return vod.getPlayAuth(params.vid)//页面上的变量名
            .then(response=>{
                return{
                    playAuth:response.data.data.playAuth,
                    vid:params.vid
                }
            })
    },
    mounted(){//页面渲染之后执行
        var player = new Aliplayer({
            id: 'J_prismPlayer',
            width: '100%',
            height:'500px',
            autoplay: true,
            cover: 'http://liveroom-img.oss-cn-qingdao.aliyuncs.com/logo.png',  
            encryptType:'1',//如果播放加密视频设置encryptType=1，不加密的不设置
            vid:this.vid,//视频id
            playauth:this.playAuth
            },
            function(player){
            console.log('播放器创建好了。')
            });
    }




}
</script>